home *** CD-ROM | disk | FTP | other *** search
/ Venus 7000 / darktronics.iso / Software / Service Packs / Win2kSP4.exe / i386 / mmc.ex_ / mmc.exe / HTML / JSCOMMON.JS < prev    next >
Encoding:
JavaScript  |  2003-06-19  |  4.3 KB  |  168 lines

  1. //****************************        
  2. // CLICK EVENT HELPER FUNCTION
  3. //****************************
  4.  
  5. function SymbolClickHandler(theIndex)
  6. {
  7.     // Determine what type of action to take
  8.     // based on value in gaiBtnActionType array
  9.     
  10.     switch (gaiBtnActionType[theIndex])
  11.     {
  12.         case 0:     // MMC_TASK_ACTION_ID:
  13.             ExecuteCommandID (gaszBtnActionClsid[theIndex], gaiBtnActionID[theIndex], 0);
  14.             break;
  15.  
  16.         case 1:     // MMC_TASK_ACTION_LINK:
  17.             // Allow default navigation to continue; defer to <A HREF> tag
  18.             window.event.returnValue = true;
  19.             break;
  20.  
  21.         case 2:     // MMC_TASK_ACTION_SCRIPT:
  22.             // Determine whether the language is (JSCRIPT | JAVASCRIPT) or (VBSCRIPT | VBS)
  23.             // Convert toUpperCase
  24.             var szLanguage = gaszBtnActionScriptLanguage[theIndex].toUpperCase();
  25.                         
  26.             switch (szLanguage)
  27.             {
  28.                 case "JSCRIPT":
  29.                 case "JAVASCRIPT":
  30.                     // Pass a script string to the JSObject to be evaluated and executed
  31.                     // through the eval method (this can be a semi-colon delimited complex expression)
  32.                     eval (gaszBtnActionScript[theIndex]);
  33.                     break;
  34.  
  35.                 case "VBSCRIPT":
  36.                 case "VBS":
  37.                     // Use the window.execScript method to execute a simple or complex VBScript expression
  38.                     window.execScript (gaszBtnActionScript[theIndex], szLanguage);
  39.                     break;
  40.  
  41.                 default:
  42.                     var L_UnknownScriptingLanguage_ErrorMessage = "Unrecognized scripting language.";
  43.                     alert (L_UnknownScriptingLanguage_ErrorMessage);
  44.                     break;
  45.             }
  46.             break;
  47.  
  48.         default:
  49.             var L_UnknownTask_ErrorMessage = "Unrecognized task.";
  50.             alert (L_UnknownTask_ErrorMessage);
  51.             break;
  52.     }
  53. }
  54.  
  55. //***************************************************
  56. // CIC TASK NOTIFY HELPER FUNCTION (ExecuteCommandID)
  57. //***************************************************
  58.  
  59. function ExecuteCommandID(szClsid, arg, param)
  60. {
  61.    MMCCtrl.TaskNotify (szClsid, arg, param);
  62. }
  63.  
  64. //***********************************
  65. // EOT & FONT-FAMILY HELPER FUNCTIONS
  66. //***********************************
  67.  
  68. function IsUniqueEOT(szURLtoEOT)
  69. {
  70.     // Get the length of the test array
  71.     var iLength = gaszURLtoEOTUnique.length;
  72.  
  73.     // If the length is empty, return true
  74.     // since the EOT *must* be unique
  75.     if (iLength == 0) {
  76.         return true;
  77.     }
  78.     
  79.     // Compare with each existing entry in the array
  80.     for (var i = 0; i < iLength; i++) {
  81.         if (gaszURLtoEOTUnique[i] == szURLtoEOT) {
  82.             // Found a duplicate
  83.             return false;
  84.         }
  85.     }
  86.     
  87.     // If we made it this far, the EOT is unique
  88.     return true;
  89. }
  90.  
  91. function AddUniqueEOT(szEOT, szFontFamilyName)
  92. {
  93.     // Use the length of the EOT array to get the
  94.     // index for the next element to be added
  95.     var iNextIndex = gaszURLtoEOTUnique.length;
  96.     gaszURLtoEOTUnique[iNextIndex] = szEOT;
  97.     gaszFontFamilyNameUnique[iNextIndex] = szFontFamilyName;
  98. }
  99.  
  100. //***************
  101. //COLOR FUNCTIONS
  102. //***************
  103.  
  104. function SynchTooltipColorsToSystem()
  105. {
  106.     tblTooltip.style.backgroundColor = "infobackground";
  107.     tblTooltip.style.color = "infotext";
  108.     divTooltipPointer.style.color = "buttonshadow";
  109.     
  110.     // Show a one-pixel border around the divTooltip
  111.     divTooltip.style.borderWidth = 1;
  112. }
  113.  
  114. //*****************
  115. //UTILITY FUNCTIONS
  116. //*****************
  117.  
  118. function GetSmallerDimension()
  119. {
  120.     //Purpose: Returns the smaller of clientHeight or clientWidth
  121.     var cw = document.body.clientWidth;
  122.     var ch = document.body.clientHeight;
  123.     
  124.     //Get smaller of clientWidth or clientHeight
  125.     if (cw <= ch) {
  126.         if (cw >= 0) {
  127.             return cw;
  128.         }
  129.     }
  130.     else {
  131.         if (ch >= 0) {
  132.             return ch;
  133.         }
  134.     }
  135.     
  136.     // Return 0 if clientWidth or Height is < 0
  137.     return 0;
  138. }
  139.  
  140. function GetElementIndex(ElementID)
  141. {
  142.     // Purpose: Given an Element ID formatted as follows:
  143.     //         "divCaption_12"
  144.     // returns the numeric portion after the underscore character;
  145.     // returns -1 if delimiter not found.
  146.     
  147.     var iDelimitLoc = ElementID.indexOf("_");
  148.  
  149.     if (iDelimitLoc == -1) {
  150.         // Return -1 if delimiter not found (which shouldn't happen)
  151.         return iDelimitLoc;
  152.     }
  153.     else {
  154.         var theIndex = ElementID.substring(iDelimitLoc + 1, ElementID.length);
  155.         return theIndex;
  156.     }
  157. }
  158.  
  159. function GetPixelSize(szTheSize)
  160. {
  161.     // Purpose: Given an Element.style.fontSize formatted as follows:
  162.     //          "72px"
  163.     // returns the parsed numeric portion, discarding the "px" string at the end;
  164.     // Assumes that szTheSize is properly formatted
  165.     
  166.     return parseInt(szTheSize);
  167. }
  168.